<!doctype html>
<html lang="en">
<head>

    <meta name="description"
          content="Be Smarter and Safer. Providing location based situational intelligence for law enforcement and fire departments."/>
    <meta property='og:title' content='Police, Fire, Law Enforcement Software | FirstTwo'/>
    <meta property='og:description'
          content='Be Smarter and Safer. Providing location based situational intelligence for law enforcement and fire departments.'/>
    <meta property='og:url' content=''/>

    <title>大象技术中心日常统计监控</title>

    <meta charset="UTF-8">
    <meta name="keywords"
          content="Situational Intelligence,First Response,Situational Awareness,Police,Law Enforcement,Safety,Public Safety,Emergency,Fire,Fire Departments,EMS,Rescue,Tactical"/>
    <meta name="author" content="FirstTwo"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta property='og:type' content='website'/>
    <meta property='og:site_name' content='FirstTwo'/>
    <meta property='og:image' content=''/>
    <meta property='twitter:site' content='@firsttwo_com'/>
    <meta property='twitter:image' content=''/>
    <meta name="msvalidate.01" content="9CF98F0D5B453AB054AA6D8B0C10C34E"/>
    <meta name="apple-mobile-web-app-title" content="FirstTwo">
    <link rel="shortcut icon" href="http://www.healthmall.cn/favicon.ico"/>
    <!-- =========================
     FAV AND TOUCH ICONS
    ============================== -->


    <!-- =========================
         STYLESHEETS
    ============================== -->
    <meta charset="UTF-8">
    <!--1.添加视口标签 快捷方式：meta:vp -->
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <!--2.设置网页渲染模式  快捷方式：meta:compat  -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <!--3.把bootstrap 核心样式（压缩版）引入-->
    <link rel="stylesheet" href="/static/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="https://www.firsttwo.com/www/css/owl.theme.css">
    <link rel="stylesheet" href="https://www.firsttwo.com//www/css/owl.carousel.css">
    <link rel="stylesheet" href="https://www.firsttwo.com//www/css/jquery.vegas.min.css">
    <link rel="stylesheet" href="https://www.firsttwo.com//www/css/animate.min.css">

    <!-- CUSTOM STYLES -->
    <link rel="stylesheet" href="https://www.firsttwo.com//www/css/styles.css">
    <link rel="stylesheet" href="https://www.firsttwo.com//www/css/responsive.css">

    <style>
        table {
            color: ivory;
        }

        .pagination {
            color: #fff;
        }
    </style>
</head>

<body id="page-home">


<!-- =========================
   HOME SECTION       
============================== -->

<header id="home" class="header" style="">

    <!-- TOP BAR -->
    <div id="main-nav" class="navbar navbar-inverse bs-docs-nav" role="banner" style="background-color: #1ba354">

        <div class="container">
            <div class="navbar-header responsive-logo">
                <button class="navbar-toggle collapsed" type="button" data-toggle="collapse"
                        data-target="#bs-navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>

                </button>
                <div class="navbar-brand">
                    <a href="/"><img src="/static/img/loggo.png" style="width: 195px"></a>
                </div>
            </div>
            <nav class="navbar-collapse collapse" role="navigation" id="bs-navbar-collapse">
                <ul class="nav navbar-nav navbar-right responsive-nav main-nav-list">


                    {% if request.user.is_authenticated %}
                        <li><a id="navbar-nav-list-home" href="">欢迎登陆</a></li>
                        <li><a id="navbar-nav-list-testimonials" href="">用户名:{{ request.user }}</a></li>
                        <li><a id="navbar-nav-list-pricing" href=""> 姓名：{{ request.user.userpro.name }}</a></li>

                    {% else %}
                        <span style="color: red">登录/注册 /<a href="/accounts/logout">注销</a></span>
                    {% endif %}
                    <li><a id="navbar-nav-list-signup" style="padding: 0px 5px 0px 5px;" class="btn signup-button"
                           href="/accounts/logout">注销</a></li>
                    <li><a target="_blank" id="admin" href="admin" class="btn signup-button">后台管理</a></li>
                </ul>
            </nav>
        </div>

    </div>
    <!-- / END TOP BAR -->

    <!-- BIG HEADING WITH CALL TO ACTION BUTTONS AND SHORT MESSAGES -->
    <div class="container">

        <!-- HEADING -->
        <!-- <h1 class="intro">Situational Intelligence Now</h1> -->
        <h1 class="intro">原型托管</h1>
        <br>
        <h3 class="subintro"></h3>
        <br>
        <br>
        <h3 class="subintro"></h3>

        <!-- CALL TO ACTION BUTTONS -->
        <div class="buttons inpage-scroll">

            <table class="table table-bordered table-condensed ">
                <tr>
                    <td>序号</td>
                    <td>原型</td>
                    <td>域名</td>
                    <td>时间</td>
                    <td>操作</td>
                </tr>
                {#                                <tbody>#}
                {#                                </tbody>#}

            </table>


        </div>
        {#        <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> 上传新原型</button>#}

        <!--模态框部分-->
        <div class="modal fade" id="myModal">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button class="close" data-dismiss="modal"><span>&times;</span></button>
                        <h3 class="modal-title">原型信息编辑</h3>
                    </div>
                    <div class="modal-body">
                        <form action="" method="post" enctype="multipart/form-data">
                            {% csrf_token %}
                            <div id="编号" class="form-group clearfix">
                                <label for="" class="control-label col-md-4 text-right">编号：</label>
                                <div class="col-md-6">
                                    <input type="text" class="form-control" name="number" value="0"/>
                                </div>
                            </div>

                            <div class="form-group clearfix">
                                <label class="control-label col-md-4 text-right" for="id_原型">原型:</label>
                                <div class="col-md-6">
                                    <input class="form-control" type="text" name="原型" id="id_原型"
                                           required="">
                                </div>
                            </div>

                            <div class="form-group clearfix">
                                <label class="control-label col-md-4 text-right" for="id_域名">域名:</label>
                                <div class="col-md-6">
                                    <input class="form-control" type="text" name="域名"
                                           id="id_域名" required="">
                                </div>
                            </div>

                            <div class="form-group clearfix"><label class="control-label col-md-4 text-right"
                                                                    for="id_备注">备注:</label>
                                <div class="col-md-6">
                                    <input class="form-control" type="text" name="备注" id="id_备注"
                                           required="">
                                </div>
                            </div>
                            <div class="form-group clearfix"><label class="control-label col-md-4 text-right"
                                                                    for="id_文件">文件:</label>
                                <div class="col-md-6"><input class="form-control" type="file" name="文件" id="id_文件"
                                                             required=""></div>
                            </div>
                            {#                            {{ uf.as_p }}#}
                            <div class="modal-footer">
                                <button class="btn btn-primary close-modal" data-dismiss="modal">关闭</button>
                                <input type="submit" value="保存" class="btn btn-success save">
                            </div>

                        </form>

                    </div>

                </div>
            </div>
        </div>

        <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">删除原型</h4>
                    </div>
                    <div class="modal-body">
                        确认删除原型：<span id="确认删除"></span>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" data-dismiss="modal" id="确认删除确认">确认</button>
                    </div>
                </div>
            </div>
        </div>
    </div> <!-- / END BIG HEADING WITH CALL TO ACTION BUTTONS AND SHORT MESSAGES  -->

</header> <!-- / END HOME SECTION  -->
<button id="上传新原型" class="btn  btn-lg btn-danger" data-toggle="modal" data-target="#myModal"> 上传新原型</button>


{#-----分页-------#}
<div class="pagination pull-right">
    <span class="页的序号" data-id="{{ contacts.number }}">
        {% for i in 页的序号 %}

            <a class="btn btn-primary " href="?page={{ i }}">{{ i }}</a>

        {% endfor %}
    </span>
    <span class="step-links text-center ">
        {% if contacts.has_previous %}
            <a class="btn btn-primary" href="?page={{ contacts.previous_page_number }}">上一页</a>
        {% endif %}

        <span class="current text-center">
             第{{ contacts.number }} 页,共 {{ contacts.paginator.num_pages }}页.
        </span>

        {% if contacts.has_next %}
            <a class="btn btn-primary" href="?page={{ contacts.next_page_number }}">下一页</a>
        {% endif %}
    </span>
</div>

<!--4.把jQuery 引入-->
<script src="/static/js/jquery-1.10.2.min.js"></script>
<!--5.把bootstrap 核心脚本文件（压缩版）引入-->
<script src="/static/js/bootstrap.min.js"></script>
<script>
    $(function () {
        var 页的序号 = $('.页的序号').data('id');
        $("[href='?page=" + 页的序号 + "']").hide();

        $('#编号').hide();

        $('#上传新原型').click(function () {
            $.ajax({
                url: "/getdomain", type: "GET", context: document.body, async: false, success: function (getdomain) {
                    $(":text[name=域名]").val(getdomain['域名']);
                    {#                console.log(getdomain['域名'])#}
                    $(":text[name=number]").val('');
                    $(":text[name=原型]").val('');
                    $(":text[name=备注]").val('');
                }
            });
        });

        var data;

        function ajaxfunc() {
            $.ajax({
                url: "/getdata", type: "GET", context: document.body, async: false, success: function (getdata) {
                    data = getdata;
                }
            });
            var htmlStr = ''; //定义一个生成html的字符串
            for (var i in data) {
                htmlStr += '<tr id="tr' + i + '">\
                        <td>' + data[i].序号 + '</td>\
                        <td>' + data[i].原型 + '</td>\
                        <td><a target="_blank" href="' + data[i].域名 + '">' + data[i].域名 + '</a></td>\
                        <td>' + data[i].时间 + '</td>\
                        <td><a class="btn btn-primary btn-xs view" data-id="' + i + '" href="javascript:void(0)">更新</a>|<a class="btn btn-danger btn-xs delete" data-id="' + i + '" href="javascript:void(0)">删除</a></td>\
                    </tr>';
                {#            console.log(data[i])#}
            }
            var title_trtd = '<tr>\
                    <td><b>序号</b></td>\
                    <td><b>原型</b></td>\
                    <td><b>域名</b></td>\
                    <td><b>时间</b></td>\
                    <td><b>操作</b></td>\
                </tr>';
            $(".table tbody").html(title_trtd + htmlStr);

        }

        ajaxfunc();
        {#        console.log(data)#}
        setInterval(function () {
            //定时器要执行的代码
            {#            Response.Redirect("");//重新载入当页面#}
            ajaxfunc();
            {#history.go(0)#}
        }, 300000);
        //给更新添加点击事件
        $("body").on("click", '.view', function () {
            //打开模态框
            var index = $(this).data("id");//获取点击元素的数据索引值
            {#            console.log(index);#}
            $(".modal-title").html(data[index].原型 + " -原型信息编辑");//修改模态框的标题
            //设置模态框对应显示的内容
            $(":text[name=number]").val(data[index].序号);
            $(":text[name=原型]").val(data[index].原型);
            {#            $(":text[name=域名]").val(data[index].域名);#}
            $.ajax({
                url: "/getdomain", type: "GET", context: document.body, async: false, success: function (getdomain) {
                    $(":text[name=域名]").val(getdomain['域名']);
                    {#                    console.log(getdomain)#}
                }
            });

            $(":text[name=备注]").val(data[index].备注);

            $("#myModal").modal('show');//显示模态框
        });

        $("body").on("click", '.delete', function () {
            var index = $(this).data("id");//获取点击元素的数据索引值
            var 域名 = data[index]['域名'];
            var 原型 = data[index]['原型'];
            var 序号 = data[index]['序号'];
            {#            console.log(原型);#}
            $('#确认删除').text(原型);
            $("#myModal2").modal('show');//显示模态框

            $('#确认删除确认').click(function () {
                console.log('ok');
                $.get("", {'delete': 'ok', "序号": 序号}, function () {
                    $('#tr' + index).remove()
                });

            })
        });

        {#        console.log(data)#}


    })
</script>

</body>
</html>
